Tag Link | [Net->SetType] | Category | Networking |
---|---|---|---|
Type | Member | Source Available | Yes |
Support | Preferred | Version | 7.0 |
Change | Unchanged | Data Source | Any |
Output Type | None | Security | None |
Implementation | LCAPI | Sets | Lasso 8.5, Lasso 8.0, Lasso 7.0 |
The [Net->SetType] tag sets what type of connection a [Net] object uses when it accesses remote servers or listens for incoming traffic. The tag requires one parameter which is the type of connection.
[Net_TypeTCP] creates a TCP connection. This is the default if [Net->SetType] is not called so should never be necessary unless switching back to TCP communication from a different type.
[Net_TypeUDP] creates a stateless UDP connection.
[Net_TypeSSL] creates a TCP connection that uses SSL encryption.
Important: This tag actually closes the current connection and opens a new one.
<?LassoScript
Variable: 'Listener' = (Net);
$Listener->(SetType: Net_TypeUDP);
$Listener->(Bind: 8000);
$Listener->(Listen);
Variable: 'Connection' = $Listener->Accept;
...
$Connection->Close;
$Listener->Close;
?>
Required Parameters | |
---|---|
Type | The type of connection. |
To connect to a remote server using SSL:
Use the [Net] type and its member tags to establish an SSL connection. The following example opens a blocking SSL connection to the Web server running on an example server and fetches the root document. The result will be an HTML page.
[Variable: 'myConnection' = (Net)]
[$myConnection->(SetBlocking: True)]
[$myConnection->(SetType: Net_TypeSSL)]
[Var: 'Result' = $myConnection->(Connect: 'www.example.com', 591)]
[Fail_If: $Result != Net_ConnectOK, (-1), 'SSL Error']
[Variable: 'Result' = $myConnection->(Write: 'GET / HTTP/1.0\r\n\r\n')]
[Variable: 'Output' = $myConnection->(Read: 32768)]
[$myConnection->(Close)]
[Output: $Output]
<html><head><title>HTML Document</title></head>>body> ...